# -*- coding: utf-8 -*-

from WSResult import WSResult

class DnsBruteResult(WSResult):
	ips = {}
	net_errors = []
	
	def as_string(self):
		result = ""
		if len(self.ips):
			for ip in self.ips:
				result += "==========" + ip + "==========\n"
				for domain in self.ips[ip]:
					result += domain + "\n"

		if len(self.net_errors):
			result += "========== Network errors: ==========\n"
			for domain in self.net_errors:
				result += domain + "\n"
							
		return result
	
	def put(self, name_type, name, ip = ''):
		if name_type == 'error':
			self.net_errors.append(name)
		elif name_type == 'exists':
			if ip not in self.ips.keys():
				self.ips[ip] = []
			self.ips[ip].append(name)
		else:
			raise DnsBruteException("Unknown data type for domain name: " + name_type)